<?php
/**************************************************
HTML below. No form tag 
(though if you'd like to include another form, 
just close one, and open the new one right after,
like so: </form><form method="post" action="">)
***************************************************/

//Must be included at the top of all mod files.
if(!defined('DREAMSCAPE')){die('Sorry, but this file cannot be directly viewed.');}

$size_note = sprintf('<p class="notealert">%s</p>', sprintf(L_SIZE_NOTE,MAX_UPLOAD));
 ?>
<?php
//If you're adding content, use this block
if(ADDING): ?>
			<?php 
			//you can add your own custom sections by looking for $_GET variables (or any other conditions...) to check against. 
			if(isset($_GET['upload']) && $_GET['upload'] == 'mass'):
			printf(NOTE,sprintf(L_GALLERY_UPLOAD_NOTE,CMS_NAME));
			 ?>
			<?php echo $size_note; ?>
			<label for="massupload"><?php echo L_GALLERY_FILE ?></label>
			<input name="massupload" type="file" class="formfields" id="massupload" size="50" />
			<br />
			<p class="switch"><?php echo L_CONCAT_AND.'/'.L_CONCAT_OR ?></p>
			<label for="mass_upload_ftp"><?php echo L_GALLERY_MASS_UPLOAD_FTP ?></label>
			<input name="mass_upload_ftp" type="text" class="formfields" id="mass_upload_ftp" size="50" /><?php tooltip(L_GALLERY_MASS_UPLOAD_FTP, L_GALLERY_MASS_UPLOAD_FTP_HELP); ?><br />
<fieldset><legend><?php echo L_GALLERY_OPTIONAL ?></legend>
<label for="online"><?php echo L_ONLINE ?></label><input name="online" class="cBox" type="checkbox" id="online" value="1" checked="checked" /><br />
<input type="hidden" name="aid" value="<?php echo $_SESSION['id']; ?>" /><input type="hidden" name="pid" value="<?php echo $catid; ?>" />
<label for="materials"><?php echo L_MATERIALS ?></label><input name="materials" type="text" class="formfields" id="materials" /><br />

<label for="autothumb"><?php echo L_GALLERY_AUTO_THUMB ?></label><input name="autothumb" class="cBox" type="checkbox" id="autothumb" value="1" checked="checked" />
<br />


<label for="descr"><?php echo L_GALLERY_BODY ?></label><textarea name="descr" cols="30" rows="5" id="descr" class="formfields"></textarea>
 <br />

<label for="smilies"><?php echo L_USE_SMILIES ?></label><input name="smilies" class="cBox" type="checkbox" id="smilies" value="1" checked="checked" />
<br />
<label for="comments"><?php echo L_ALLOW_COMMENTS ?></label><input name="comments" class="cBox" type="checkbox" id="comments" value="1" checked="checked" />
<br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">
<?php 
$the_module->more_options(
	array(
	L_CATEGORY_OPTIONS => array('doCategories', 'simple'),
	L_GALLERY_PAYPAL_SETTINGS => 'doPaypal'
	)
);
$the_module->more_options(L_POST_TIME_ADD, 'doDateTimeForms', 'editDateTimeContainer');
?>


</div>
<?php 
printf(ALERT, L_GALLERY_EDIT_MORE_LATER);
?>
<label for="submit"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_MASS_UPLOAD ?>" />
			<?php else: 
			
			
			?>
<a href="<?php echo $_SERVER['REQUEST_URI'] ?>&upload=mass"><?php echo L_GALLERY_MASS_UPLOAD ?></a><br />
<label for="online"><?php echo L_ONLINE ?></label><input name="online" class="cBox" type="checkbox" id="online" value="1" checked="checked" /><br />
<label for="title"><?php echo L_GALLERY_TITLE ?></label><input name="title" type="text" class="formfields" id="title" /><input type="hidden" name="aid" value="<?php echo $_SESSION['id']; ?>" /><input type="hidden" name="pid" value="<?php echo $catid; ?>" /><br />

<label for="materials"><?php echo L_MATERIALS ?></label><input name="materials" type="text" class="formfields" id="materials" /><br />
<?php echo $size_note; ?>
<label for="img_main"><?php echo L_IMAGE ?></label> <input name="img_main" type="file" class="formfields" id="img_main" size="50" />
<br />
<label for="autothumb"><?php echo L_GALLERY_AUTO_THUMB ?></label><input name="autothumb" class="cBox" type="checkbox" id="autothumb" value="1" checked="checked" />
<br />
<div id="thumbField"><label for="img_thumb" id="iTLabel"><?php echo L_THUMBNAIL ?></label> <input name="img_thumb" type="file" class="formfields" id="img_thumb" size="50" />
<br /><br /></div><br />

<fieldset id="additionalImages"><legend><?php echo L_GALLERY_ADDITIONAL_IMAGES;tooltip(L_GALLERY_ADDITIONAL_IMAGES, L_GALLERY_ADDITIONAL_IMAGES_HELP) ?></legend>
<label for="additional_images1"><?php echo L_IMAGE ?> 1</label><input name="additional_images1" type="file" class="formfields" id="additional_images1" size="50" />
<br />
<label for="caption1"><?php echo L_CAPTION ?> 1</label><textarea name="caption[additional_images1]" class="caption" id="caption1"></textarea><br />
</fieldset>


<label for="descr"><?php echo L_GALLERY_BODY ?></label><textarea name="descr" cols="30" rows="5" id="descr" class="formfields"></textarea>
 <br />

<label for="smilies"><?php echo L_USE_SMILIES ?></label><input name="smilies" class="cBox" type="checkbox" id="smilies" value="1" checked="checked" />
<br />
<label for="comments"><?php echo L_ALLOW_COMMENTS ?></label><input name="comments" class="cBox" type="checkbox" id="comments" value="1" checked="checked" />
<br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">
<?php 
$the_module->more_options(
	array(
	L_CATEGORY_OPTIONS => 'doCategories',
	L_GALLERY_PAYPAL_SETTINGS => 'doPaypal'
	)
);
$the_module->more_options(L_POST_TIME_ADD, 'doDateTimeForms', 'editDateTimeContainer');
?>
</div>
<label for="submit"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_ADD ?>" />
	<?php endif; ?>
<?php endif; ?>
<?php 
//If you're editing content, use this block
if(EDITING): ?>

		<?php 
		//If you're editing one specific item, use this block
		if(EDIT_SINGLE): 
		?>
		
<label for="online"><?php echo L_ONLINE ?></label>
<input type="hidden" name="online" value="0" id="" /><input class="cBox" type="checkbox" name="online" value="1" id="online"  <?php echo ($items->online == 1) ? 'checked="checked"' : '';?> /><br />
<?php echo preview_link(); ?>

<label for="title"><?php echo L_GALLERY_TITLE ?></label>
<input name="title" type="text" class="formfields" id="title" value="<?php echo view($items->title);?>" /><br />

<label for="materials"><?php echo L_MATERIALS ?></label>
<input name="materials" type="text" class="formfields" id="materials" value="<?php echo view($items->materials);?>" /><br />
<?php echo $size_note; ?>
 <p id="thumbNails"><img src="funcs/tn.lib.php?dim=200&amp;id=<?php echo $items->id ?>&amp;<?php echo time(); ?>" alt="<?php echo $items->image ?>" id="thumbNailMain" class="thumbnails" />
 <img class="thumbnails" src="funcs/tn.lib.php?dim=75<?php echo (!$items->autothumb) ? '&manual=1' : '' ?>&thumb=1&id=<?php echo $item_id ?>&amp;<?php echo time(); ?>" alt="<?php echo $items->thumbnail ?>" id="thumbNailThumb" /><br /></p>
<label for="img_main"><?php echo L_IMAGE ?></label>
<input name="img_main" type="file" class="formfields" id="img_main" size="50" />
<br />

  <img id="canvasImg" style="display:none;" width="<?php echo $items->width; ?>" height="<?php echo $items->height; ?>" src="funcs/tn.lib.php?id=<?php echo $item_id ?>&amp;dim=11024&amp;<?php echo time(); ?>" />

<label for="autothumb"><?php echo L_GALLERY_AUTO_THUMB ?></label>
<input type="hidden" name="autothumb" value="0" /><input class="cBox" type="checkbox" id="autothumb" value="1" name="autothumb"  <?php echo ($items->autothumb == 1) ? 'checked="checked"' : '';?> /><br />
<div id="thumbField"><label for="img_thumb" id="iTLabel"><?php echo L_THUMBNAIL ?></label>
<input name="img_thumb" type="file" class="formfields" id="img_thumb" size="50" />
<br /><br /></div>
<img style="display:none;" src="funcs/tn.lib.php?thumb=1&dim=<?php echo $items->width ?>&id=<?php echo $item_id ?>&amp;<?php echo time(); ?>&amp;ignore_scale=1" alt="<?php echo $items->thumbnail ?>" id="scaleImg" name="scaleImg" />


<fieldset id="additionalImages"><legend><?php echo L_GALLERY_ADDITIONAL_IMAGES; tooltip(L_GALLERY_ADDITIONAL_IMAGES,L_GALLERY_ADDITIONAL_IMAGES_HELP); ?></legend>
<div id="extraImages"><?php 
$add_images = $images->GetList(array(array('itemid', '=', $item_id)));
$count = count($add_images);
$count++;
foreach($add_images as $ximg){
?>
<div class="imgBox">
<label for="delete_additional<?php echo $ximg->id ?>"><?php echo L_GALLERY_ADDITIONAL_IMAGES_DELETE ?></label><input type="checkbox" id="delete_additional<?php echo $ximg->id ?>" name="delete_additional[]" value="<?php echo $ximg->id ?>" class="xtraImgDelete" />
<img src="funcs/tn.lib.php?image_id=<?php echo $ximg->id ?>&amp;dim=50" title="<?php echo view($ximg->caption); ?>" alt="<?php echo view($ximg->caption); ?>" id="addImg<?php echo $ximg->id ?>" class="thumbnails hasHelp" /><blockquote class="helpContents" id="addImg<?php echo $ximg->id ?>Help"><h5>Image caption</h5><?php echo view($ximg->caption); ?></blockquote> </div>
<?php
}
 ?></div><br />
<label for="additional_images1"><?php echo L_IMAGE ?> <?php echo $count; ?></label><input name="additional_images1" type="file" class="formfields" id="additional_images1" size="50" />
<br />
<label for="caption1">Caption <?php echo $count; ?></label><textarea name="caption[additional_images1]" class="caption" id="caption1"></textarea>
<br />
</fieldset>
<label for="descr"><?php echo L_GALLERY_BODY ?></label><textarea name="descr" cols="30" rows="5" id="descr" class="formfields"><?php echo view($items->descr); ?></textarea> <br />

<label for="smilies"><?php echo L_USE_SMILIES ?></label><input type="hidden" name="smilies" value="0" /><input class="cBox" type="checkbox" name="smilies" value="1" id="smilies"  <?php echo ($items->smilies == 1) ? 'checked="checked"' : '';?><?php echo $items->smilies;?> /><br />
<label for="comments"><?php echo L_ALLOW_COMMENTS ?></label><input type="hidden" name="comments" value="0" id="" /><input class="cBox" type="checkbox" name="comments" value="1" id="comments"  <?php echo ($items->comments == 1) ? 'checked="checked"' : '';?>  /><br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">
<?php 
$the_module->more_options(
	array(
	L_CATEGORY_OPTIONS => 'doCategories',
	L_CLEAN_URL_TITLES => 'doCleanURLTitles',
	L_GALLERY_PAYPAL_SETTINGS => 'doPaypal'
	)
);
$the_module->more_options(L_GALLERY_THUMBNAIL_SETTINGS,'doThumbnails','thumbInfoContents');
$the_module->more_options(L_SHARE_ITEM, 'doSharing', 'sharing');
$the_module->more_options(L_POST_TIME_EDIT, 'doDateTimeForms', 'editDateTimeContainer');
?>
</div>
<br />
<label for="submit"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_EDIT ?>" />

		<?php elseif(EDIT_LIST): ?>
		<?php $the_module->doSort(); ?>
			<?php
			$itemsList = paginate($itemsList, '', EDIT_LIMIT);
			$numitems = count($itemsList);
			$hasitems = $numitems ? true : false;
			?>
			<div id="itemList">
			<?php 
			foreach($itemsList as $ind => $item):
			$item->title = trim_title($item->title);
			$item->descr = trim_excerpt($item->descr);
			$users->Get($item->aid);
			$the_displayname = $users->displayname;
			$the_username = $users->username;
			$has_subcat = ($item->cid != $item->pid && $item->cid != 0) ? true : false;
			if($has_subcat){
				$sections->Get($item->cid);
				$category = $sections->sectionname;
				if(empty($category)){
				$has_subcat = false;
				}
			}
			?>
			<div id="item_<?php echo $item->id ?>">
	  <img class="thumbnails" src="funcs/tn.lib.php?dim=70&thumb=1&id=<?php echo $item->id ?>" alt="<?php echo $item->thumbnail ?>" /><h1><?php echo $item->title ?></h1>
      <h2 class="<?php echo ($item->online == 0) ? 'offline' : 'online'; ?>"><?php echo ($item->online == 0) ? L_ITEM_OFFLINE : L_ITEM_ONLINE; ?></h2>
      <h3><?php printf(L_POSTED_BY, $the_displayname, $the_username); ?></h3>
     <?php if($has_subcat){
	 ?> <h3><?php echo L_SUB_CATEGORY ?>: <?php echo $category; ?></h3><?php 
	 }
	 ?>
      <a href="<?php echo edit_link($item->id); ?>" title="<?php echo L_EDIT_ITEM ?>"><?php echo L_EDIT_ITEM ?></a> <br />
<a href="<?php echo edit_link($item->id); ?>#sharing" title="<?php echo L_SHARE_ITEM ?>" class="shareLink"><?php echo L_SHARE_ITEM ?></a> 
	  <fieldset>
 <label for="item_delete_<?php echo $item->id; ?>"><?php echo L_DELETE_ITEM ?></label><input type="checkbox" name="del[]" value="<?php echo $item->id; ?>" id="item_delete_<?php echo $item->id; ?>" /><br />

</fieldset>
	  </div>
			<?php 
			endforeach;
			?>
			<input type="hidden" value="<?php echo getOption('sortcats'); ?>" id="order_by" />
			</div>
			
<?php if($hasitems){ ?><label for="submit"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_DELETE ?>" /><?php } ?>
		<?php endif; ?>
		
<?php endif; ?>
